function isBlank(data){
	if(!data){
		return 1;
	}else{
		return 0;
	}
}

layui.use([ 'element', 'form', 'laydate' ], function() {
	var element = layui.element(), form = layui.form(),laydate = layui.laydate;

	form.verify({
        organizeName : function(value) {
            var organizeName = $('#organizeName').val();
            var msg = "";
			$.ajax({
				type : "post",
				url : rootPath + "/washingFactory/isExist.shtml?organizeName="+organizeName,
				cache : false,
				async : false,
				dataType : "json",
				success : function(obj) {
					if (!obj.status) {
						console.log(!obj.status+"===="+obj.message);
						msg = obj.message;
						return obj.message;
					}
				}
			});
			if (msg!="") {
				return msg;
			}
		}
	});

	form.on('submit(formSubmit)', function(data) {
		if(isBlank(data.field.contactsPhone) || isBlank(data.field.organizeAddress) || isBlank(data.field.organizeContacts)
            || isBlank(data.field.organizeName)){
            alert("请填写完整数据！！！");
            return;
		}else{

		}
		$.post(rootPath + "/washingFactory/addWashFactory.shtml", data.field, function(result) {
			if (!result.status) {
				layer.msg(result.message, {
					icon : 5,
					shift : 6
				});
			} else {
                parent.layer.close(parent.layer.index);
				layer.msg('添加成功', {
					icon : 1
				});
				parent.refreshWashingFactoryList();
            }
		}, "json");
		return false;
	});
});